<?php
// +----------------------------------------------------------------------
// | Copyright (c) 2023 yoncron All rights reserved.
// +----------------------------------------------------------------------
// | Author: yoncron <yoncron@163.com>
// +----------------------------------------------------------------------
namespace app\controller\app\im;

use app\controller\app\AppBase;
use app\model\GroupMembersModel;
use app\model\GroupModel;
use app\service\Route;
use support\Response;

class Group extends AppBase
{
    public function beforeAction(){
        $rtn = parent::beforeAction();
        if($rtn instanceof Response){
            return $rtn;
        }
    }

    /**
     * description:群组
     * @Route(reqUrl="/im.group.lst")
     * author:yoncron<yoncron@163.com>
     * data:2023/11/03
     */
    public function lst(){
        $groupObj = new GroupModel();
        $groupMemberObj = new GroupMembersModel();
        $group_id_lst = $groupMemberObj->where('uid','=',$this->user_id)->column('gid');
        $group_lst = $groupObj->where('gid','in',$group_id_lst)->select();
        $res['code'] = 0;
        $res['list'] = $group_lst;
        $res['count'] = count($group_lst);
        return json($res);
    }
}